import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;

/**
 * Jordan Lange
 */
public class Tetris {
    // Shape constraints are defined by a given rectangle and the given points NOT filled by the shape
    // (0 based index)
    // ie, LREG defines a shape 2 blocks wide (max 1 index) and 3 blocks tall (max 2 index)
    // with the top second block and the second block in the second row blacked out.
    // shown below
    
    /* Stars show blacked out area
     * []*
     * []*
     * [][]
     */
    public enum Shape { 
        LREG    (new Color(227, 219, 13), 2, 3, new Point[]{new Point(1, 0), new Point(1, 1)}),
        SOPP    (new Color(7, 147, 20), 3, 2, new Point[]{new Point(2, 0), new Point(0, 1)}),
        BAR     (new Color(206, 21, 2), 1, 4, new Point[]{}),
        LOPP    (new Color(143, 4, 134), 2, 3, new Point[]{new Point(0,0), new Point(0,1)}),
        SREG    (new Color(14, 71, 188), 3, 2, new Point[]{new Point(0,0), new Point(2,1)}),
        SQUARE  (Color.ORANGE, 2, 2, new Point[]{}),
        T       (Color.WHITE, 3, 2, new Point[]{new Point(0, 1), new Point(2, 1)});

        private final Color pColor;
        private final Dimension dim;
        private final int[][] constraint;

        Shape(Color c, int x, int y, Point[] pts) {
            pColor = c;
            dim = new Dimension(x, y);
            constraint = new int[x][y];
            // a -1 in the constraint indicates that the piece does not occupy that part of the rectangle
            for (Point p : pts) {
                constraint[p.x][p.y] = -1;
            }
        }
        public Dimension getGridDimension() {
            return dim;
        }
        public Color getColor() {
            return pColor;
        }
        public int[][] getConstraint() {
            return constraint;
        }
    }

    public static Tetris.Shape getRandomShape() {
        Shape[] shapes = Shape.values();
        return shapes[(int)(Math.random() * shapes.length)];
    }

    public static void main(String[] args) {
        TetrisFrame frame = new TetrisFrame();
        frame.setVisible(true);
    }
}
